﻿@model Tuple<VacancyModel, Web.HelperClasses.Inflexion.IWordFormatter>

@{
	ViewBag.Title = "VacancyDescription";
}

<tr>
    <td class="project_participantList_post_container">
        <span class="project_participantList_post">@Model.Item1.Vacancy.Name</span>
		<div class="project_participantList_post_description">
            @Model.Item1.Vacancy.Description
		</div>
		<div style="height:20px; overflow:hidden;">
        <a href="javascript:void(0)" class="showLightBox_link editButton_edit editButton" title="редактировать" rel="vacancyBox" onclick="setVacancyEditData(@Model.Item1.Vacancy.Id, '@Model.Item1.Vacancy.Name','@Model.Item1.Vacancy.Description', @Model.Item1.Vacancy.NeededNumber, @(Model.Item1.Vacancy.ApprovalRequired ? "true" : "false"))" >редактировать</a>
        <a href="javascript:void(0)" class="showLightBox_link editButton_remove editButton" title="удалить" rel="removeVacancyBox" onclick="setVacancyRemoveData(@Model.Item1.Vacancy.Id, '@Model.Item1.Vacancy.Name')" >удалить</a>
        </div>
	</td>
    <td class="project_participantList_counter_container">
    @if (Model.Item1.Vacancy.NeedsMore && !Model.Item1.IsProjectCompleted)
    {
        <span class="project_participantList_counter">
             Требуется еще @Model.Item1.Vacancy.NeededMore @(Model.Item2.GetNumericalWordForm((string)"человек", (int)Model.Item1.Vacancy.NeededMore))
			<span class="project_participantList_counter_description">@(Model.Item1.Vacancy.ApprovalRequired ? "с одобрения организатора" : "")</span>
		</span>
    }
@if (!Model.Item1.IsProjectCompleted)
{
    if (Model.Item1.Vacancy.NeedsMore)
    {
        if (!Model.Item1.IsAuthenticated)
        {
	    <input type="button" class="project_participantList_joinLink showLightBox_link" rel="registerOrLogInBox" value="Записаться"/>
        }
        else if (Model.Item1.CanApply)
        {
            var needApproval = Model.Item1.Vacancy.ApprovalRequired ? "needApprovalForm" : "";
            using (Html.BeginForm("Apply", "Vacancy", FormMethod.Post, new { @class = "ajaxForm " + needApproval }))
            {
		<input type="submit" class="project_participantList_joinLink" value="Записаться" onclick="$(this).hide();"/>
	    <input type="hidden" name="id" value="@Model.Item1.Vacancy.Id" />	
            }
        }
    }
    else
    {
        <span>пока больше не требуется</span>
    }
} 
	@if (Model.Item1.IsMyProject && Model.Item1.AppliedUsers.Count > 0)
 {
	 
		<div class="project_participantList_moderation">
            Предложили себя:

			@for (int i = 0; i < Model.Item1.AppliedUsers.Count; ++i)
   {
	 
            <div class="project_pretendent">
            @if (!Model.Item1.IsProjectCompleted)
            {
			    using (Html.BeginForm("TurnDown", "Vacancy", FormMethod.Post, new { @class = "ajaxForm" }))
                {
				    @Html.Hidden("vacancyId", Model.Item1.Vacancy.Id)
				    @Html.Hidden("userId", Model.Item1.AppliedUsers[i].Id)
                    <input type="submit" class="project_pretendent_denny" value="Отказать"/>
                }
		        using (Html.BeginForm("Approve", "Vacancy", FormMethod.Post, new { @class = "ajaxForm" }))
                {
				    @Html.Hidden("vacancyId", Model.Item1.Vacancy.Id)
			        @Html.Hidden("userId", Model.Item1.AppliedUsers[i].Id)
                    <input type="submit" class="project_pretendent_allow" value="Принять"/>
                }
            }
                <a href="@Url.Action("View", "User", new { id = @Model.Item1.AppliedUsers[i].Id })" class="project_pretendentAvatar_container">
                    @Avatar.Small(Model.Item1.AppliedUsers[i], imageClass: "project_pretendentAvatar")
                </a>
                <a href="@Url.Action("View", "User", new { id = @Model.Item1.AppliedUsers[i].Id })" class="project_pretendentPerson">
                    @(Model.Item1.AppliedUsers[i].DisplayName ?? "unknown")
                </a>
            </div>
   }
        </div>
 }
	</td>
	<td class="project_participantList_peoplesList_container">
        <ul class="project_participantList_peoplesList">
	@for (int i = 0; i < Model.Item1.SelectedUsers.Count; ++i)
 {
            <li class='project_participantList_peoplesList_item_container @(i == Model.Item1.MyselfPos ? " project_participantList_peoplesList_itsMe" : "")'>
                <a href="@Url.Action("View", "User", new { Model.Item1.SelectedUsers[i].Id })" class="project_participantList_peoplesList_item">
					@Avatar.Small(Model.Item1.SelectedUsers[i], imageClass: "project_participantList_peoplesList_item_image")
				</a>
			</li>
 }
		</ul>
		<a class="project_participantList_peoplesList_description" href="@Url.Action("Participants", "Vacancy", new { Model.Item1.Vacancy.Id })">
            всего @Model.Item1.Vacancy.UsersApproved.Count @(Model.Item2.GetNumericalWordForm((string)"человек", (int)Model.Item1.Vacancy.UsersApproved.Count))
		</a>
		@if (Model.Item1.MyselfPos != -1 && !Model.Item1.IsProjectCompleted)
  {
	  using (Html.BeginForm("Revoke", "Vacancy", FormMethod.Post, new { @class = "ajaxForm" }))
	  {
		   <div class="project_participantList_peoplesList_itsMe_undo_container">
				<input type="hidden" name="vacancyId" value="@Model.Item1.Vacancy.Id" />	
				<input type="hidden" name="userId" value="@Model.Item1.CurrentUserId" />
                Вы участвуете в проекте <input type="submit" class="project_participantList_peoplesList_itsMe_undo_link" value="Отказаться"/>
				</div>
	   }
  }
	</td>
</tr>
<tr>
<td colspan="3" style="font-size:2px;"><hr/></td>
</tr>
